local skel = fk.CreateSkill {
  name = "emo__chuancheng",
  tags = {Skill.Compulsory},
}

skel:addEffect(fk.Deathed, {
  can_trigger = function (self, event, target, player, data)
    return player:hasSkill(skel.name, false, true) and target == player
  end,
  on_cost = function (self, event, target, player, data)
    local room = player.room
    local targets = table.filter(room.alive_players, function (p) return not p:hasSkill(skel.name, true) end)
    if #targets == 0 then return end
    if #targets > 1 then
      targets = room:askToChoosePlayers(player, {
        max_num = 1, min_num = 1, skill_name = skel.name, cancelable = false, targets = targets,
        prompt = "#emo__chuancheng-choose",
      })
    end
    event:setCostData(self, {tos = targets})
    return true
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    local to = event:getCostData(self).tos[1]
    room:handleAddLoseSkills(to, "emo__guangguang")
    player:chat("光不灭")
  end,
})


Fk:loadTranslationTable{
  ["emo__chuancheng"] = "传承",
  [":emo__chuancheng"] = "锁定技，你死亡后，令一名角色获得[光！]。",
  ["#emo__chuancheng-choose"] = "传承：选择一名角色，令其获得[光！]",

  ["$emo__chuancheng1"] = "光不灭",
}

return skel
